#include "Camera.h"

Camera::Camera(double _aratio, double *_pos, double *_look_at)
{
	aratio = _aratio;
	pos = _pos;
	look_at = _look_at;
	camera_type = CAMERA_POSITION;
}

Camera::Camera(double _aratio, double *_look_at, double _distance, double _anglex, double _angley)
{
	pos = new double[3];
	aratio = _aratio;
	look_at = _look_at;
	anglex = _anglex;
	angley = _angley;
	distance = _distance;
	zoom = 60.0;
	camera_type = CAMERA_DISTANCE;
}

Camera::~Camera()
{
	// empty?
}

void Camera::updateProjection()
{
	glMatrixMode(GL_PROJECTION);
	glLoadIdentity();
	//if (camera_type == CAMERA_DISTANCE)
	//{
		gluPerspective( zoom, aratio, 1.0, 10000.0 );
	//}
}

void Camera::updateModelview()
{
	glMatrixMode(GL_MODELVIEW);
	glLoadIdentity();
	if (camera_type == CAMERA_DISTANCE)
	{
		gluLookAt(0, 0, -distance, look_at[0], look_at[1], look_at[2], 0, 1, 0);
		glRotated(angley, 1, 0, 0);
		glRotated(anglex, 0, 1, 0);
	} else {
		gluLookAt(0, 0, 0, look_at[0], look_at[1], look_at[2], 0, 1, 0);
		glTranslatef(-pos[0], -pos[1], -pos[2]);
	}
}